package org.kyw.auth.service.impl;

import org.kyw.auth.domain.Role;
import org.kyw.auth.mapper.RoleMapper;
import org.kyw.auth.query.RoleQuery;
import org.kyw.auth.service.IRoleService;
import org.kyw.basic.service.impl.BaseServiceImpl;
import org.kyw.basic.util.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public class RoleServiceImpl extends BaseServiceImpl<Role> implements IRoleService {
    @Autowired
    private RoleMapper roleMapper;

    @Override
    @Transactional
    public void addPermission(Long roleId, Long[] permissionIds) {
        //1.删除当前角色原有的权限
        roleMapper.deleteRolePermissionByRoleId(roleId);

        //2.给当前角色授权
        roleMapper.addPermission(roleId, permissionIds);

    }

}
